package cn.pegasus.teamwork.util;

import java.util.UUID;

public abstract class IDGenerator {
	private final static String DEFAULT_PREFIX_TITLE = "MC";
	public static final String USERS_PREFIX_TITLE = "ZF";//会员中心前缀
	public static final String SYSTEM_USER_PREFIX_TITLE = "SYSU"; // 系统用户
	public static final String SYSTEM_ROLE_PREFIX_TITLE = "SYSR"; // 系统角色
	public static final String SYSTEM_MENU_PREFIX_TITLE = "SYSM"; // 系统菜单
	public static final String SYSTEM_FORBID_PREFIX_TITLE = "SYSF"; // 系统禁用词汇
	public static final String SYSTEM_SALES_PREFIX_TITLE = "SYSA"; // 系统业务员
	public static final String BI_PREFIX_TITLE = "BI"; //数据中心

	/**
	 * 生成序列ID
	 * 
	 * @规则 两位前缀标识+当前服务器时间戳+两位随机数字
	 * @return String
	 */
	public synchronized static String get() {
		return get(DEFAULT_PREFIX_TITLE);
	}

	/**
	 * 自定义前缀标识生成序列ID
	 * 
	 * @param prefix
	 *            前缀标识
	 * @return String
	 */
	public synchronized static String get(String prefix) {
		return String.format("%s%s", prefix,  UUID.randomUUID().toString().replaceAll("-", "").toUpperCase());
	}


	public static void main(String[] args) {
		String testID = IDGenerator.get();
		System.err.println(testID.length());
		System.err.println(testID);
	}
}
